package com.gu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gu.entity.EduTeacher;
import com.gu.service.EduTeacherService;
import com.gu.mapper.EduTeacherMapper;
import org.springframework.stereotype.Service;

/**
 *
 */
@Service
public class EduTeacherServiceImpl extends ServiceImpl<EduTeacherMapper, EduTeacher>
    implements EduTeacherService{

    /**
     * 前台功能显示区域
     * */
    @Override
    public Page<EduTeacher> getTeacherForIndex() {
        //传给前端 前4个 高等级 教师；
        QueryWrapper<EduTeacher> wrapper = new QueryWrapper<>();
        Page<EduTeacher> teacherPage = new Page<>(1,4);
        wrapper.orderByAsc("sort");
        Page<EduTeacher> Page = this.page(teacherPage, wrapper);
        return Page ;
    }


    /**
     * 后台教师查询显示区域
     * */
    @Override
    public Page<EduTeacher> getFrontTeacherList(String current) {
        //要求分页，并且按照等级从高到底排列
        long now = Long.parseLong(current);
        Page<EduTeacher> teacherPage = new Page<EduTeacher>(now, 8);
        QueryWrapper<EduTeacher> eduTeacherQueryWrapper = new QueryWrapper<>();
        eduTeacherQueryWrapper.orderByDesc("level");
        Page<EduTeacher> page = this.page(teacherPage, eduTeacherQueryWrapper);
        return page ;
    }
}




